package com.ruoyi.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class LogDocAddressRunner implements ApplicationRunner {
    private final Environment environment;

    public LogDocAddressRunner(Environment environment) {
        this.environment = environment;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String port = environment.getProperty("server.port", "8080");
        String contextPath = environment.getProperty("server.servlet.context-path", "/");
        if (contextPath.equals("/")) {
            contextPath = "";
        }
        log.info("doc 文档地址： " + String.format("http://localhost:%s%s/doc.html", port, contextPath));
    }
}
